<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="../../../common/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<%@ include file="../../../common/meta.jsp"%>
		<link rel="stylesheet" href="${path}/css/jquery.autocomplete.css"
			type="text/css"></link>
		<script type="text/javascript"
			src="${path }/script/jquery.autocomplete.js">
</script>
		<style type="text/css">
#title {
	display: block;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	width: 70px;
}
</style>
		<script type="text/javascript">	
$(function() {
 	 
	$("#fullScreen").click(function() {
		fullScreen.FullScreen("mylist");
	});
	$(".stop").click(
			function() {
				var productID = $(this).attr("val");
				var url = "${path}/productandtrain/product/index/stopnotice/"
						+ productID;
				art.dialog( {
					lock : true,
					content : '确定要停售吗?',
					ok : function() {
						art.dialog( {
							id : "loading",
							lock : true,
							drag : false,
							resize : false,
							title : "正在更改状态..."
						});
						$.post(url, null, function(result) {
							art.dialog( {
								id : 'loading'
							}).close();//关闭等待框
								if (result == "true") {
									art.dialog( {
										icon : "succeed",
										content : "修改成功!",
										lock : true,
										ok : function() {
											location.reload();
										}
									});
								} else {
									art.dialog( {
										icon : "error",
										content : "修改失败!",
										lock : true,
										ok : true
									});
								}

							});

						return true;
					},
					cancelVal : '关闭',
					cancel : true
				//为true等价于function(){}
						});
			});
});
$(document).ready(function() {
	var requestUrl = "${path}/common/index/getprovider";
	var Url = "${path}/common/index/getproduct";
	$.ajax( {
		type : "post",//默认为get   
		dataType : "json",
		url : requestUrl,
		success : function(providerList) {
			// 供应商
		$("#provides").autocomplete(providerList, {
			minChars : 0,
			max : 200,
			width : 200,
			matchContains : "word",
			autoFill : true,
			formatItem : function(row, i, max) {
				return row.providercode + ":" + row.providerabbr;
			},
			formatMatch : function(row, i, max) {
				return row.providercode + ":" + row.providerabbr;
			},
			formatResult : function(row) {
				return row.providercode + ":" + row.providerabbr;
			}
		});
	}
	});
	$.ajax( {
		type : "post",//默认为get   
		dataType : "json",
		url : Url,
		success : function(providerList) {
			//产品代码
		$("#productCode").autocomplete(providerList, {
			minChars : 0,
			max : 200,
			width : 200,
			matchContains : "word",
			autoFill : true,
			formatItem : function(row, i, max) {
				return row.productcode;
			},
			formatMatch : function(row, i, max) {
				return row.productcode;
			},
			formatResult : function(row) {
				return row.productcode;
			}
		});
		//产品名称
		$("#productname").autocomplete(providerList, {
			minChars : 0,
			max : 200,
			width : 200,
			matchContains : "word",
			autoFill : true,
			formatItem : function(row, i, max) {
				return row.productname;
			},
			formatMatch : function(row, i, max) {
				return row.productname;
			},
			formatResult : function(row) {
				return row.productname;
			}
		});

	}
	});

});
  
</script>
</head>
	<body id="master">

		<sfa:mainHeader></sfa:mainHeader>
		<div class="webpart3 contentarea">
			<div class="webpart-head">
				<div class="webpart-head-item">
					产品管理
					<div class="tools-btn">
						<a href="####" id="fullScreen"><span> <img
									src="${path}/statics/images/qp.gif"
									style="margin-right: 4px; margin-bottom: -3px;" />全屏</span> </a>

					</div>
				</div>
			</div>
			<div class="webpart-main">
				<div class="webpart-main-item" style="padding-top: 12px;">
					<div class="search">
						<!----------- 查询信息 ------------------>
						<form method="get" id ="rest">
							<table cellpadding="0" cellspacing="0">
								<tr>
									<th>
										供应商
									</th>
									<td>
										<input type="text" name="provides" id="provides"
											class="input-txt" value="${productSupplier}" />
									</td>
									<th>
										产品代码
									</th>
									<td>
										<input type="text" class="input-txt" name="productCode"
											id="productCode" value="${productCode}" />
									</td>
									<th>
										产品名称
									</th>
									<td>
										<input type="text" name="productname" id="productname"
											value="${productTitle}" class="input-txt" />
									</td>

								</tr>
								<tr>
									<th>
										起售日期始
									</th>
									<td>
										<input id="createdatebegin" name="datebegin" type="text"
											onClick="WdatePicker()" class="Wdate inputbox"
											readOnly="true" value="${datebegin}" />
									</td>
									<th>
										起售日期止
									</th>
									<td>
										<input id="createdatebegin" name="dateend" type="text"
											onClick="WdatePicker()" class="Wdate inputbox"
											readOnly="true" value="${dateend}" />
									</td>
									<th>
										所属机构
									</th>
									<td>
										<select class="selectbox" name="branchId" id="branchId">
											<option value="ALL">
												全部
											</option>
											<c:forEach items="${BranchList}" var="branch">
												<option value="${branch.branchId }"
													<c:if test="${branchId==branch.branchId }">selected='selected'</c:if>>
													${branch.branchName}
												</option>
											</c:forEach>
										</select>
									</td>
								</tr>
								<tr>
									<th>
										停售日期始
									</th>
									<td>
										<input id="stopdatebegin" name="stopdatebegin" type="text"
											onClick="WdatePicker()" class="Wdate inputbox"
											readOnly="true" value="${stopdatebegin}" />
									</td>
									<th>
										停售日期止
									</th>
									<td>
										<input id="stopdateend" name="stopdateend" type="text"
											onClick="WdatePicker()" class="Wdate inputbox"
											readOnly="true" value="${stopdateend}" />
									</td>
									<th>
										状态
									</th>
									<td>
										<select class="selectbox" name="releasetatus">
											<option value="ALL"
												<c:if test='${releasetatus=="ALL"}'>selected=selected</c:if>>
												全部
											</option>
											<option value="1"
												<c:if test='${releasetatus=="1"}'>selected=selected</c:if>>
												未发布
											</option>
											<option value="2"
												<c:if test='${releasetatus=="2"}'>selected=selected</c:if>>
												已发布
											</option>
										</select>
									</td>


								</tr>
								<tr>
									<th>
										销售渠道
									</th>
									<td>

										<sfa:dic showType="select" kindNo="CHANNELTYPE"
											code="${channeltype}" def="ALL:全部;" attr="class='input-txt'"
											name="channeltype" id="channeltype"></sfa:dic>
									</td>
									<th>
										销售状态
									</th>
									<td>

										<sfa:dic showType="select" kindNo="SALESTATUS"
											code="${salestatus}" def="ALL:全部;" attr="class='input-txt'"
											name="salestatus" id="salestatus"></sfa:dic>
									</td>
								</tr>
								<tr>
									<td align="center" width="100%" colspan="5">
										<input type="submit" class="linkbtn2" value="查询" />
										<input type="button" class="linkbtn2"
											onclick="location.href='${path}/productandtrain/product/index';"
											value="重置" />
									</td>
								</tr>
							</table>
						</form>
					</div>
					<div id="mylist">
						<table cellpadding="0" cellspacing="0"
							class="dg_borderstyle trStyleTable" style="margin-top: 15px;">
							<tr>
								<th>
									序号
								</th>
								<th>
									供应商
								</th>
								<th>
									产品代码
								</th>
								<th>
									产品名称
								</th>

								<th>
									起售时间
								</th>
								<th>
									止售时间
								</th>
								<th>
									销售状态
								</th>

								<th>
									状态
								</th>
								<th>
									操作
								</th>
							</tr>

							<c:forEach items="${pagination.resultList}" var="product"
								varStatus="ind">
								<tr>
									<td align="center">
										${(pagination.page-1)*10+(ind.index+1)}
									</td>
									<td align="center" width="70">
										<div
											style="display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 70px;"
											title="${product.PROVIDERNAME}">
											${product.PROVIDERNAME}

										</div>
									</td>
									<td align="center" width="90px;">
										<div
											style="display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 90px;"
											title="${product.PRODUCTCODE}">
											${product.PRODUCTCODE}
										</div>
									</td>
									<td align="left" width="70px;">
										<a id="title"
											href="${path}/productandtrain/product/index/info/${product.productid}"
											title="${product.PRODUCTNAME}">${product.PRODUCTNAME}</a>
									</td>

									<td align="center">
										<fmt:formatDate value="${product.SALESTARTDATE}"
											pattern="yyyy-MM-dd" />
									</td>
									<td align="center">
										<fmt:formatDate value="${product.SALEENDDATE}"
											pattern="yyyy-MM-dd" />
									</td>
									<td align="center">
										${product.statusname}
									</td>
									<td align="center">
										<c:if test="${product.stopnotice != '停售'}">
									${product.PUBLISHSTATUS}
								</c:if>
										<c:if test="${product.stopnotice == '停售'}">
									${product.stopnotice}
								</c:if>
									</td>
									<td align="center">
										<c:if
											test='${product.statusname == "在售" && product.publishStatus=="未发布" }'>
											<a class="publish"
												href="${path}/productandtrain/product/index/publish/${product.productid}">发
												布 </a>
										</c:if>
										<c:if test="${product.stopnotice == '停售'}">
											<a class="publish"
												href="${path}/productandtrain/product/index/publish/${product.productid}">发
												布 </a>
										</c:if>
										<c:if
											test='${product.statusname =="停售" && product.publishStatus=="未发布" }'>
											<font color="red">已停售</font>
										</c:if>
										<c:if
											test='${product.publishStatus=="已发布" && product.statusname =="停售" && product.stopnotice =="停售" }'>
											<font color="red">已停售</font>
										</c:if>
										<c:if
											test='${product.publishStatus=="已发布" && product.stopnotice !="停售"}'>
											<a class="stop" href="javascript:void(0);"
												val="${product.productid}">停售</a>|
									</c:if>
										<c:if
											test='${product.publishStatus=="已发布" && product.stopnotice !="停售"}'>
											<a class="adjunct"
												href="${path}/productandtrain/product/index/publish/${product.productid}">修改
											</a>
										</c:if>
										|
										<a
											href="${path}/productandtrain/product/index/info/${product.productid}">查看</a>
									</td>
								</tr>
							</c:forEach>
						</table>
						<!----------- 翻页导航 ------------------>
						<div class="dg_pagerstyle">
							<div class="pageinfo">
								<c:if test="${not empty pagination.multiPage}">
						   第${pagination.page }页 | 共${pagination.totalPages }页/${pagination.totalRows }条记录
						</c:if>
							</div>
							<div class="pagebtn">
								${pagination.multiPage}
							</div>
						</div>
					</div>
				</div>
				<div class="webpart-foot">
					<div class="webpart-foot-item">
					</div>
				</div>
			</div>
		</div>
		<sfa:mainFooter></sfa:mainFooter>
	</body>
</html>